<?php session_start();?>
<?php
include "Datasource.php";
include "Customer.php";
include "CustomerDao.php";

//create connection to database
$conn = new Datasource("localhost","theanykey","root","");
//print("DS Good"); //Used for testing

//create dao object to interact with database
$customerDao = new CustomerDao();
//print("DAO Good"); //Used for testing

//create new customer valueObject and populate with data from post
$customer = new Customer();
$id = $_POST["CustID"];
$customer->setAll($id, $_POST["CustomerLast"],
    $_POST["CustomerFirst"], $_POST["CustomerAddress"],
    $_POST["CustomerCity"], $_POST["CustomerState"],
    $_POST["CustomerZip"], $_POST["CustomerPhone1"],
    $_POST["CustomerPhone2"], $_POST["CustomerPhone3"],
    $_POST["CustomerEmail"]);

//print("Cust Good"); //Used for testing

//send valueObject to dao so that it can be added to database
$customerDao->save($conn, $customer);


//print($customer->toString()); //Used for testing

?>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="maintenancePagesCSS.css" />
        <title></title>
    </head>
    <body>
    <center>
 <table width="1000" height="662" border="0" background="images/background.jpg">
              <tr>
                <th height="526" scope="col"><center>
                  <p><img src="images/TitleCustomerInformation.gif" alt="Customer Information" width="514" height="67"></p>
                  <table border="0" class="EditTable">
                    
                    <tbody>
                      <tr>
                        <td>Customer ID:</td>
                        <td><?php print($customer->getCustomerID());  ?></td>
                      </tr>
                      <tr>
                        <td>Last Name:</td>
                        <td><?php print($customer->getLastName());  ?></td>
                      </tr>
                      <tr>
                        <td>First Name:</td>
                        <td><?php print($customer->getFirstName());  ?></td>
                      </tr>
                      <tr>
                        <td>Address:</td>
                        <td><?php print($customer->getAddress());  ?></td>
                      </tr>
                      <tr>
                        <td>City:</td>
                        <td><?php print($customer->getCity());  ?></td>
                      </tr>
                      <tr>
                        <td>State:</td>
                        <td><?php print($customer->getState());  ?></td>
                      </tr>
                      <tr>
                        <td>Zip:</td>
                        <td><?php print($customer->getZip());  ?></td>
                      </tr>
                      <tr>
                        <td>Phone 1:</td>
                        <td><?php print($customer->getPhoneNumber1());  ?></td>
                      </tr>
                      <tr>
                        <td>Phone 2:</td>
                        <td><?php print($customer->getPhoneNumber2());  ?></td>
                      </tr>
                      <tr>
                        <td>Phone 3:</td>
                        <td><?php print($customer->getPhoneNumber3());  ?></td>
                      </tr>
                      <tr>
                        <td>Email:</td>
                        <td><?php print($customer->getEmail());  ?></td>
                      </tr>
                      <tr>
                        <td colspan=2> <div align="center"><U>Customer successfully updated in database. </U></div></td>
                      </tr>
                    </tbody>
                  </table>
                </center>
                  <center>
                  <BR><BR>
                  <script src="links.js" language="javascript" type="text/javascript"></script>
                  <script type="text/javascript">
                      writeCustomerLinks("", "");
                  </script>
                  </center>                </th>
              </tr>
              <tr>
                <th height="130" scope="col">&nbsp;</th>
              </tr>
            </table>
        <p>&nbsp;</p>
      </center>
      </body>
</html>
